/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufba.lasid.v1.jitclouds.mda.datatypes.virtualization;

import br.ufba.lasid.v1.jitclouds.mda.datatypes.BasicMachine;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.GuestList;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.IGuest;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.IMachine;

/**
 *
 * @author aliriosa
 */
public class BasicHypervisor extends BasicMachine implements IHypervisor {
    
    private IMachine host = null;
    
    @Override
    public VirtualMachineList getMachines() {
        VirtualMachineList machines = new VirtualMachineList();
        GuestList guests = getGuests();
        
        for(IGuest guest : guests){
            IVirtualMachine machine = (IVirtualMachine) guest;
            machines.add(machine);
        }
        return machines;
    }

    @Override
    public void addVirtualMachine(String idMachine, IVirtualMachine machine) {
        machine.setHypervisor(this);
        addGuest(idMachine, machine);
    }

    @Override
    public void delVirtualMachine(String idMachine) {
        getVirtualMachine(idMachine).setHypervisor(null);
        delGuest(idMachine);
    }

    @Override
    public IVirtualMachine getVirtualMachine(String idMachine) {
        return (IVirtualMachine) getGuest(idMachine);
    }

    @Override
    public void execute(String idMachine, String command) {
        getVirtualMachine(idMachine).execute(command);
    }

    @Override
    public IMachine getHost() {
        return this.host;
    }

    @Override
    public void setHost(IMachine host) {
        this.host = host;
    }

    @Override
    public boolean isLocal() {
        return host.isLocal();
    }

    @Override
    public void setLocal(boolean local) {
        host.setLocal(local);
    }

    public String getName() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void connect() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    

}
